<?php
	/*	 
	 * @author: Tran Van Thanh
	 * Email  : thanhtran@vietnambiz.com
	 * Date:	07/09/2011
	 */
class Reviews_model extends MY_Model{

	function __construct()
	{
		parent::__construct();		
	}
	
	function get_all_reviews($limit = 1, $offset = 1)
	{			
        $q      =       $this->db->select('a.*,b.fullname,b.position,b.logo')
                             ->from("reviews as a")                 
                 			 ->join('customers as b','b.id = a.id_customer')                 			                 			                    
                             ->limit($limit,$offset)
                             ->order_by('a.date_create DESC')
                             ->get();
        
        $result			= 	array();
        $result['rows'] 	=	$q->result();
        $q->free_result();

        $q      =	$this->db->select('count(a.id) as cnt')
                             ->from("reviews as a")
                             ->get();
        $result['num_rows']	=	$q->row()->cnt;
        $q->free_result();
        return	$result;
	}
}